<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<meta charset="UTF-8">
	<title>站点数据</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" th:href="@{/resources/favicon.ico}">
	<link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all"/>
	<link rel="stylesheet" th:href="@{/resources/css/public.css}" media="all"/>
</head>
<style>
	.layui-form-item {
		margin-bottom: 5px;
		clear: both;
		*zoom: 1;
	}
</style>
<body class="childrenBody">
<!-- 查询条件开始 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 5px;">
	<legend>查询条件</legend>
</fieldset>
<blockquote class="layui-elem-quote">
	<form method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form-pane">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">CustID</label>
				<div class="layui-input-inline">
					<input type="text" name="custid"  autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">客户名称</label>
				<div class="layui-input-inline">
					<input type="text" name="customer"  autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">联系方式</label>
				<div class="layui-input-inline">
					<input type="text" name="telephone"  autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">提交人</label>
				<div class="layui-input-inline">
					<input type="text" name="founder" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">创建开始</label>
				<div class="layui-input-inline">
					<input type="tel" name="startTime" id="startTime" readonly="readonly"   class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">创建结束</label>
				<div class="layui-input-inline">
					<input type="tel" name="endTime"  id="endTime"  readonly="readonly"   class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">更新开始</label>
				<div class="layui-input-inline">
					<input type="tel" name="startUpdateTime" id="startUpdateTime" readonly="readonly"   class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">更新结束</label>
				<div class="layui-input-inline">
					<input type="tel" name="endUpdateTime"  id="endUpdateTime"  readonly="readonly"   class="layui-input">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block" style="text-align: center;margin-left: 0px">
				<button type="button" id="doSearch" class="layui-btn" lay-submit="" lay-filter="doSearch"><span class="layui-icon layui-icon-search"></span>查询</button>
				<button type="button" id="doReset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
			</div>
		</div>
	</form>
</blockquote>
<!-- 查询条件结束-->

<!-- 数据表格开始 -->
<div>
	<table class="layui-hide" id="customerTable" lay-filter="customerTable"></table>
	<div id="customerToolBar" style="display: none;">
		<button type="button" shiro:hasPermission="customer:create" lay-event="add" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-add-1"></span>添加客户</button>
		<button type="button" shiro:hasPermission="customer:update" lay-event="update" class="layui-btn layui-btn-sm"><span class="layui-icon layui-icon-edit"></span>更新</button>
		<button type="button" shiro:hasPermission="customer:selectsitebycustomer" id="selectsitebycustomer" lay-event="selectsitebycustomer" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe63c;</i>查看该客户下所有站点</button>
		<button type="button" shiro:hasPermission="customer:delete" lay-event="delete" class="layui-btn layui-btn-sm layui-btn-danger"><span class="layui-icon layui-icon-delete"></span>删除</button>
		<button type="button" shiro:hasPermission="customer:batchdelete"  lay-event="batchDelete" class="layui-btn layui-btn-sm layui-btn-danger"><span class="layui-icon layui-icon-delete"></span>批量删除</button>
	</div>
</div>
<!-- 数据表格结束 -->

<!-- 添加和修改的弹出层开始 -->
<div style="display: none;padding: 5px" id="addOrUpdateDiv">
	<form action="" method="post" class="layui-form layui-form-pane" id="dataFrm" lay-filter="dataFrm">
		<div class="layui-form-item" style="display: block;margin-bottom: 0px;margin-top: 0px">
			<fieldset>
				<legend>客户信息</legend>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">CustID</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 87px" name="custid" autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="color: red">客户名称</label>
						<div class="layui-input-block">
							<input type="hidden" name="id">
							<input type="text" style="display: inline-block;width: 154px" name="customer" lay-verify="required"  autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">姓名</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 153px" name="person"  autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系方式</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 154px" name="telephone" autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">站点数量</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 87px" name="sitenum" autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">站点名称</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="site" autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">职务</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="post" autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label">省份</label>
						<div class="layui-input-inline">
							<select name="address" id="address" lay-filter="address">
								<option value="0">请选择省份</option>
							</select>
						</div>
					</div>
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label">城市</label>
						<div class="layui-input-inline">
							<select name="city" id="city" lay-filter="city">
								<option value="0">请选择城市</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label">部署方式</label>
						<div class="layui-input-inline">
							<select name="deployment" id="deployment">
								<option value="0">请选择部署方式</option>
							</select>
						</div>
					</div>
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label" style="color: red">客户类型</label>
						<div class="layui-input-inline">
							<select name="customertype" id="customertype">
								<option value="0">请选择客户类型</option>
							</select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">帮我吧ID</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="help" autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">问题处理状态</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="problem" autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
			</fieldset>
			<fieldset>
				<legend>站点程序/中心程序版本</legend>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">95A2网点</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c95a2"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">中心数据库</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="centerdb"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9511油站</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9511"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size:13px">9511数据库</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9511db"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">7100便利店</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c7100"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">7800便利店</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c7800"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">95A1</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c95a1"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9001制卡</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9001"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">9581零管</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9581"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">9599室内扣款</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9599"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">9512</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="c9512"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">云智付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="cloud"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">传输</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="transfer"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">账户数量</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="accounts"   autocomplete="off"  class="layui-input">
						</div>
					</div>
                    <div class="layui-inline" style="display: inline-block;margin-right: 0px">
                        <label class="layui-form-label" style="color: red">产品类型</label>
                        <div class="layui-input-inline">
                            <select name="product" id="product">
                                <option value="0">请选择产品类型</option>
                            </select>
                        </div>
                    </div>
				</div>
			</fieldset>
			<fieldset>
				<legend>其他程序版本</legend>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">32寸屏</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="p32"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">15寸屏</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="p15"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">5.8寸屏</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="p58"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">青蛙付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="frog"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">自助服务机</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="selfservice"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">掌厅</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="palmhall"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">掌站</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="masterstation"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline" style="display: inline-block;margin-right: 0px">
						<label class="layui-form-label" style="font-size: 11px;">档案信息来源</label>
						<div class="layui-input-inline">
							<select name="sourceofcustomer" id="sourceofcustomer">
								<option value="0">请选择档案信息来源</option>
							</select>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">移动支付接口</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="payment"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">支付通道</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="paychannel"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">线上/线下支付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="onlineandoffline"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">核销小程序</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="closure"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">云闪付</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="flashpay"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">圈存机</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="transference"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">清分清算</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="clean"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="font-size: 11px">油机使用情况</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 190px" name="oilengine"   autocomplete="off" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">特殊应用</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 295px" name="specialapp"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">其他应用</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 295px" name="otherapp"   autocomplete="off"  class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">备注</label>
						<div class="layui-input-block">
							<input type="text" style="display: inline-block;width: 295px" name="message"   autocomplete="off"  class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block" style="text-align: center;margin-left: 0px">
						<button type="button" class="layui-btn" lay-submit="" lay-filter="doSubmit" id="doSubmit" ><span class="layui-icon layui-icon-add-1"></span>提交</button>
						<button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
					</div>
				</div>
			</fieldset>
		</div>
	</form>
</div>
<!-- 添加和修改的弹出层结束 -->

<!-- 查找该客户下所有站点弹出层开始 -->
<div style="display: none;padding: 5px" id="loadSiteByCustomer">
	<table class="layui-hide" id="siteTable" lay-filter="siteTable"></table>
</div>
<!-- 查找该客户下所有站点弹出层结束 -->

<script type="text/javascript" th:src="@{/resources/layui/layui.js}"></script>
<script type="text/javascript">
	layui.use(['jquery','form','table','layer','laydate','layedit'],function(){
		var $=layui.jquery;
		var form=layui.form;
		var table=layui.table;
		var layer=layui.layer;
		var laydate=layui.laydate;
		var layedit=layui.layedit;
		//初始化时间选择器
		laydate.render({
			elem:'#startTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#endTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#startUpdateTime',
			type:'datetime'
		});
		laydate.render({
			elem:'#endUpdateTime',
			type:'datetime'
		});
		//初始化富文本
		var editIndex = layedit.build('content');
		//加载 数据
		var tableIns=table.render({
			elem: '#customerTable'
			,url:'/customer/loadAllCustomer'
			,toolbar: '#customerToolBar' //开启头部工具栏，并为其绑定左侧模板
			,title: '客户档案'
			,height:'full-250'
			,limit:'20'
			,limits:[20,40,60,80]
			,page: true
			,cols: [ [
				{type: 'checkbox', fixed: 'left'}
				,{field:'id', title:'ID',align:'center',width:'100'}
				,{field:'custid', title:'CustID',align:'center',width:'100'}
				,{field:'customer', title:'客户名称',align:'center',width:'150'}
				,{field:'site', title:'站点名称',align:'center',width:'150'}
				,{field:'person', title:'姓名',align:'center',width:'100'}
				,{field:'post', title:'职务',align:'center',width:'90'}
				,{field:'telephone', title:'联系方式',align:'center',width:'150'}
				,{field:'help', title:'帮我吧ID',align:'center',width:'120'}
				,{field:'address', title:'省份',align:'center',width:'140'}
				,{field:'city', title:'城市',align:'center',width:'140'}
				,{field:'sitenum', title:'站点数量',align:'center',width:'90'}
				,{field:'deployment', title:'部署方式',align:'center',width:'140'}
				,{field:'c95a1', title:'95A1',align:'center',width:'140'}
				,{field:'centerdb', title:'中心数据库',align:'center',width:'140'}
				,{field:'c9581', title:'9581零管',align:'center',width:'140'}
				,{field:'transfer', title:'传输',align:'center',width:'140'}
				,{field:'c9001', title:'9001制卡',align:'center',width:'140'}
				,{field:'c95a2', title:'95A2网点',align:'center',width:'140'}
				,{field:'c9511', title:'9511油站',align:'center',width:'140'}
				,{field:'c9511db', title:'9511数据库',align:'center',width:'140'}
				,{field:'c7100', title:'7100便利店',align:'center',width:'140'}
				,{field:'c7800', title:'7800便利店中心',align:'center',width:'140'}
				,{field:'c9512', title:'9512',align:'center',width:'140'}
				,{field:'c9599', title:'9599室内扣款',align:'center',width:'140'}
				,{field:'cloud', title:'云智付',align:'center',width:'140'}
				,{field:'frog', title:'青蛙付',align:'center',width:'140'}
				,{field:'p32', title:'32寸屏',align:'center',width:'140'}
				,{field:'p15', title:'15寸屏',align:'center',width:'140'}
				,{field:'p58', title:'5.8寸屏',align:'center',width:'140'}
				,{field:'transference', title:'圈存机',align:'center',width:'140'}
				,{field:'selfservice', title:'自助服务机',align:'center',width:'140'}
				,{field:'palmhall', title:'掌厅',align:'center',width:'100'}
				,{field:'masterstation', title:'掌站',align:'center',width:'100'}
				,{field:'closure', title:'核销小程序',align:'center',width:'140'}
				,{field:'payment', title:'移动支付接口',align:'center',width:'140'}
				,{field:'paychannel', title:'支付通道',align:'center',width:'140'}
				,{field:'onlineandoffline', title:'线上/线下支付',align:'center',width:'140'}
				,{field:'accounts', title:'账户数量',align:'center',width:'140'}
				,{field:'flashpay', title:'云闪付',align:'center',width:'140'}
				,{field:'product', title:'产品类型',align:'center',width:'140'}
				,{field:'message', title:'备注',align:'center',width:'140'}
				,{field:'oilengine', title:'油机使用情况',align:'center',width:'140'}
				,{field:'clean', title:'清分清算',align:'center',width:'140'}
				,{field:'specialapp', title:'特殊应用',align:'center',width:'140'}
				,{field:'otherapp', title:'其他应用',align:'center',width:'140'}
				,{field:'customertype', title:'客户类型',align:'center',width:'140'}
				,{field:'sourceofcustomer', title:'客户来源',align:'center',width:'100'}
				,{field:'founder', title:'创建人',align:'center',width:'100'}
				,{field:'createtime', title:'创建时间',align:'center',width:'180'}
				,{field:'updatebody', title:'更新人',align:'center',width:'100'}
				,{field:'updatetime', title:'更新时间',align:'center',width:'180'}
				,{field:'problem', title:'问题处理状态',align:'center',width:'180'}
				// ,{fixed: 'right', title:'操作', toolbar: '#siteRowBar',align:'center',width:'250'}
			] ]
		});

		//模糊查询
		$("#doSearch").click(function () {
			var params=$("#searchFrm").serialize();
			tableIns.reload({
				url:'/customer/loadAllCustomer?'+params,
				page:{
					curr:1
				}
			});
			return false;
		})
		$("#doReset").click(function () {
			$("#searchFrm")[0].reset()
			$("#doSearch").click()
		})
		var data;
		//监听工具条的事件
		table.on("toolbar(customerTable)",function(obj){
			switch(obj.event){
				case 'update':
					var checkStatus = table.checkStatus('customerTable');
					var data =checkStatus.data[0];
					openUpdateSiteLayer(data);
					break;
				case 'delete':
					var checkStatus = table.checkStatus('customerTable');
					var data =checkStatus.data[0];
					deleteCustomer(data);
					break;
				case 'batchDelete':
					batchDelete();
					break;
				case 'add':
					openAddLayer();
					break;
				case 'selectsitebycustomer':
					var checkStatus = table.checkStatus('customerTable');
					var data =checkStatus.data[0];
					loadSiteByCustomer(data);
					break;
			}
		});

		var mainIndex;
		var url;
		//打开添加的弹出层
		function openAddLayer(){
			mainIndex=layer.open({
				type:1,
				content:$("#addOrUpdateDiv"),
				area:['1350px','780px'],
				title:'添加客户',
				success:function(){
					$("#dataFrm")[0].reset();
					url="/customer/addCustomer";
					initDeploymentSelects();
					initSourceOfCustomerSelects();
					initProvinceSelects();
					initProductTypeSelects();
					initCustomerTypeSelects();
				}
			});
		}
		//查找该客户下所有站点的弹出层
		function loadSiteByCustomer(data){
			mainIndex=layer.open({
				type:1,
				content:$("#loadSiteByCustomer"),
				area:['1350px','630px'],
				title:'查看该客户下所有站点',
				success:function(){
					table.render({
						elem: '#siteTable'
						,url:'/site/loadSiteByCustomer?customer=' + data.customer
						,title: '站点数据'
						,limit:'10'
						,limits:[10,20,40,60,80]
                        ,page: true
						,cols: [ [
							 {type: 'numbers', title:'序号',fixed: 'left'}
							,{field:'id', title:'ID',align:'center',width:'100'}
							,{field:'custid', title:'CustID',align:'center',width:'100'}
							,{field:'customer', title:'客户名称',align:'center',width:'150'}
							,{field:'sitename', title:'站点名称',align:'center',width:'180'}
							,{field:'name', title:'姓名',align:'center',width:'100'}
							,{field:'post', title:'职位',align:'center',width:'100'}
							,{field:'telephone', title:'联系方式',align:'center',width:'150'}
							,{field:'help', title:'帮我吧ID',align:'center',width:'140'}
							,{field:'deployment', title:'部署方式',align:'center',width:'100'}
							,{field:'s95a1v', title:'95A1',align:'center',width:'140'}
							,{field:'s95a2v', title:'95A2',align:'center',width:'140'}
							,{field:'s9511v', title:'9511',align:'center',width:'140'}
							,{field:'s9512v', title:'9512',align:'center',width:'140'}
							,{field:'s9001v', title:'9001',align:'center',width:'140'}
							,{field:'s9592v', title:'9592',align:'center',width:'140'}
							,{field:'centerdbv', title:'中心数据库',align:'center',width:'140'}
							,{field:'oildbv', title:'油站数据库',align:'center',width:'140'}
							,{field:'cloudv', title:'云智付',align:'center',width:'140'}
							,{field:'frogv', title:'青蛙付',align:'center',width:'140'}
							,{field:'wisdom', title:'智慧大屏',align:'center',width:'140'}
							,{field:'selfservice', title:'自助服务机',align:'center',width:'140'}
							,{field:'oilengine', title:'油机情况',align:'center',width:'140'}
							,{field:'message', title:'备注',align:'center',width:'150'}
						] ]
					});
				}
			});
		}
		//加载部署方式数据下拉列表
		function initDeploymentSelect(data){
			var dom=$("#deployment");
			dom.html("");
			$.get("/customer/loadAllDeploymentSelect",function(res){
				var redata=res.data;
				var dom=$("#deployment");
				var html='<option value="0">请选择部署方式</option>'
				$.each(redata,function(index,item){
					if(data.deployment===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initDeploymentSelects(){
			var dom=$("#deployment");
			dom.html("");
			$.get("/customer/loadAllDeploymentSelect",function(res){
				var data=res.data;
				var dom=$("#deployment");
				var html='<option value="0">请选择部署方式</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//加载客户来源类型下拉列表
		function initSourceOfCustomerSelect(data){
			var dom=$("#sourceofcustomer");
			dom.html("");
			$.get("/customer/loadAllSourceOfCustomerSelect",function(res){
				var redata=res.data;
				var dom=$("#sourceofcustomer");
				var html='<option value="0">请选择档案信息来源</option>'
				$.each(redata,function(index,item){
					if(data.sourceofcustomer===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initSourceOfCustomerSelects(){
			var dom=$("#sourceofcustomer");
			dom.html("");
			$.get("/customer/loadAllSourceOfCustomerSelect",function(res){
				var data=res.data;
				var dom=$("#sourceofcustomer");
				var html='<option value="0">请选择档案信息来源</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//加载产品类型下拉菜单
		function initProductTypeSelect(data){
			var dom=$("#product");
			dom.html("");
			$.get("/customer/loadAllProductType",function(res){
				var redata=res.data;
				var dom=$("#product");
				var html='<option value="0">请选择产品类型</option>'
				$.each(redata,function(index,item){
					if(data.product===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initProductTypeSelects(){
			var dom=$("#product");
			dom.html("");
			$.get("/customer/loadAllProductType",function(res){
				var data=res.data;
				var dom=$("#product");
				var html='<option value="0">请选择产品类型</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//加载客户类型下拉菜单
		function initCustomerTypeSelect(data){
			var dom=$("#customertype");
			dom.html("");
			$.get("/customer/loadAllCustomerType",function(res){
				var redata=res.data;
				var dom=$("#customertype");
				var html='<option value="0">请选择客户类型</option>'
				$.each(redata,function(index,item){
					if(data.customertype===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initCustomerTypeSelects(){
			var dom=$("#customertype");
			dom.html("");
			$.get("/customer/loadAllCustomerType",function(res){
				var data=res.data;
				var dom=$("#customertype");
				var html='<option value="0">请选择客户类型</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//加载省份数据的下拉菜单
		function initProvinceSelect(data){
			var dom=$("#address");
			dom.html("");
			$.get("/customer/loadAllProvinceSelect",function(res){
				var redata=res.data;
				var dom=$("#address");
				var html='<option value="0">请选择省份</option>'
				$.each(redata,function(index,item){
					if(data.address===item.deployment){
						html+='<option value="'+item.id+'" selected>'+item.deployment+'</option>'
					}else{
						html+='<option value="'+item.id+'">'+item.deployment+'</option>'
					}
				});
				dom.html(html);
				form.render("select");
			});
		}
		function initProvinceSelects(){
			var dom=$("#address");
			dom.html("");
			$.get("/customer/loadAllProvinceSelect",function(res){
				var data=res.data;
				var dom=$("#address");
				var html='<option value="0">请选择省份</option>'
				$.each(data,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//监听添加页面的省份下拉框的改变事件
		form.on('select(address)', function(data){
			var addressid=data.value;
			initCitySelectByAddressId(addressid);
		});
		//加载省份对应城市的的下拉菜单
		function initCitySelectByAddressId(addressid){
			var dom=$("#city");
			dom.html("");
			$.get("/customer/loadCityByAddressId",{addressid:addressid},function(res){
				var redata=res.data;
				var dom=$("#city");
				var html='<option value="0">请选择城市</option>'
				$.each(redata,function(index,item){
					html+='<option value="'+item.id+'">'+item.deployment+'</option>'
				});
				dom.html(html);
				form.render("select");
			});
		}
		//打开修改的弹出层
		function openUpdateSiteLayer(data){
			mainIndex=layer.open({
				type:1,
				content:$("#addOrUpdateDiv"),
				area:['1350px','780px'],
				title:'修改客户',
				success:function(){
					$("#dataFrm")[0].reset();
					form.val("dataFrm",data);
					layedit.setContent(editIndex,data);
					url="/customer/updateCustomer";
					initDeploymentSelect(data);
					initSourceOfCustomerSelect(data);
					initProvinceSelect(data);
					initProductTypeSelect(data);
					initCustomerTypeSelect(data);
				}
			});
		}
		$("#doSubmit").click(function(){
			layedit.sync(editIndex);
			var data=$("#dataFrm").serialize();
			$.post(url,data,function(res){
				if(res.code==200){
					tableIns.reload();
					layer.close(mainIndex);
				}
				layer.msg(res.msg);
			})
		})
		//删除
		function deleteCustomer(data){
			layer.confirm('你确定要删除【'+data.customer+data.site+'】这条客户档案吗?【客户名下所有站点档案将会被删除】', {icon: 3, title:'提示'}, function(index){
				$.post("/customer/deleteCustomer",{id:data.id},function(res){
					if(res.code==200){
						tableIns.reload();
					}
					layer.msg(res.msg);
				})
				layer.close(index);
			});
		}

		//批量删除
		function  batchDelete(){
			//得到选中行
			var checkStatus = table.checkStatus('customerTable');
			var dataLength=checkStatus.data.length;
			if(dataLength>0){
				layer.confirm('你确定要删除这些客户档案吗?【客户名下所有站点档案将会被删除】', {icon: 3, title:'提示'}, function(index){
					var data=checkStatus.data; //获取选中行的数据
					var ids="";
					$.each(data,function(index,item){
						if(index==0){
							ids+="ids="+item.id;
						}else{
							ids+="&ids="+item.id;
						}
					})
					$.post("/customer/batchDeleteCustomer",ids,function(res){
						if(res.code==200){
							tableIns.reload();
						}
						layer.msg(res.msg);
					})
					layer.close(index);
				});
			}else{
				layer.msg("请选中操作行")
			}
		}
	});
</script>
</body>
</html>
